// ===============================================
// ${NAME}
// 
// Create by Will on ${DATE} ${TIME}
// Copyright @${PROJECT_NAME}.All rights reserved.
// ===============================================

import 'dart:convert';

#set($GEN_CLASS_NAME = "_$" + $CLASS_NAME)
import 'package:json_annotation/json_annotation.dart';

/// This allows the `${CLASS_NAME}` class to access private members in
/// the generated file. The value for this is *.g.dart, where
/// the star denotes the source file name.
part '${NAME}.g.dart';

/// An annotation for the code generator to know that this class needs the
/// JSON serialization logic to be generated.
@JsonSerializable(explicitToJson: true)
class ${CLASS_NAME} {

const ${CLASS_NAME}(this.id);

/// A necessary factory constructor for creating a new ${CLASS_NAME} instance
/// from a map. Pass the map to the generated `${GEN_CLASS_NAME}FromJson()` constructor.
/// The constructor is named after the source class, in this case, ${CLASS_NAME}.
factory ${CLASS_NAME}.fromJson(Map<String, dynamic> json) => ${GEN_CLASS_NAME}FromJson(json);


final int? id;

/// `toJson` is the convention for a class to declare support for serialization
/// to JSON. The implementation simply calls the private, generated
/// helper method `${GEN_CLASS_NAME}ToJson`.
Map<String, dynamic> toJson() => ${GEN_CLASS_NAME}ToJson(this);


bool isEmpty() {
  const ${CLASS_NAME} entity = ${CLASS_NAME}();
  return jsonEncode(entity) == jsonEncode(this);
}

bool isNoEmpty() {
  const ${CLASS_NAME} entity = ${CLASS_NAME}();
  return jsonEncode(entity) != jsonEncode(this);
}
}